//
//  HomeMaiChongLayerView.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/28.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "HomeMaiChongLayerView.h"
#import "CATRadarView.h"
#import "GLGWSpeechRecognizer.h"

@interface HomeMaiChongLayerView ()
@end

@implementation HomeMaiChongLayerView

-(id)initWithSayVoiceView{
    if (self = [super initWithFrame:kAppWindow.bounds inSuperView:kAppWindow]) {
        UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
        UIVisualEffectView *HUDView = [[UIVisualEffectView alloc] initWithEffect:blur];
        HUDView.alpha = 0.95f;
        HUDView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
        [self addSubview:HUDView];
        
        CATRadarView * radarView = [[CATRadarView alloc] initWithFrame:CGRectMake(-kWidthProportion_In_iPhoneTriploid(50), kHeightProportion_In_iPhoneTriploid(20), KScreenWidth+kWidthProportion_In_iPhoneTriploid(100), KScreenWidth+kWidthProportion_In_iPhoneTriploid(100))];
        [self addSubview:radarView];
        radarView.fillColor = kColor_Rule_Yellow;
        radarView.instanceCount = 6;
        radarView.instanceDelay = 0.8;
        radarView.animationDuration = radarView.instanceCount* radarView.instanceDelay;
        radarView.opacityValue = 1.0f;
        [radarView startAnimation];
        //
        GLGWButton * topBut = [[GLGWButton alloc] initInSuperView:self];
        topBut.image_Name = @"icon_yuyin copy";
        topBut.size = CGSizeMake(kWidthProportion_In_iPhoneTriploid(120), kWidthProportion_In_iPhoneTriploid(120));
        topBut.center = radarView.center;
        topBut.layer.cornerRadius = kWidthProportion_In_iPhoneTriploid(60);
        topBut.layer.masksToBounds = YES;
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            topBut.backgroundColor = [UIColor colorWithHexString:@"#A89A60" alpha:0.8];
        });
        //
        GLGWLabel * titStr = [[GLGWLabel alloc] initWithFrame:CGRectMake(0, kY_With_View(topBut, 75), KScreenWidth, kHeightProportion_In_iPhoneTriploid(20)) theFont:SYSTEMFONT(14) theColor:[UIColor colorWithHexString:@"#FFFFFF"] inSuperView:self];
        titStr.textAlignment = NSTextAlignmentCenter;
        titStr.text = @"正在识别中";
        //
        GLGWImageView * dianImageView = [[GLGWImageView alloc] initInSuperView:self];
        dianImageView.size = CGSizeMake(kWidthProportion_In_iPhoneTriploid(42), 2);
        dianImageView.centerX = titStr.centerX;
        dianImageView.y = kY_With_View(titStr, 6);
        dianImageView.imageName = @"icon_sixDian";
        //
        [GLGWSpeechRecognizer glgw_AudioRecognizerResult:^(NSString * _Nonnull resText, NSError * _Nonnull error) {
            DLog(@"  🍎🍎🍎🍎🍎🍎       %@",resText);
        }];
        [GLGWSpeechRecognizer glgw_AudioRecognizerResultEnd:^{
            [radarView stopAnimation];
            [self removeFromSuperview];
        }];
    }
    return self;
}

@end
